#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define min_(x, y) ((x) < (y) ? (x) : (y))

int arr[26];
char pd[10000007];
int nn, k; long long sum = 0;
void dfs(int i, int n, int res) {
    if (n == 0) {
        if (!pd[res]) ++sum, pd[res] = 1;
        return ;
    }
    for ( ; i + n - 1 <= nn; ++i) {
        dfs(i + 1, n - 1, res * arr[i] % 10000007);
    }
}
signed main() {
    
    scanf("%d %d", &nn, &k);
    for (int i = 1; i <= nn; ++ i) scanf("%d", arr + i);
    dfs(1, abs(k * 2 <= nn ? k : nn - k), 1);
    printf("%lld", sum);
    return 0;
}
